package nc.ui.zzjs.bd.chnlmanager;

import nc.bs.logging.Logger;
import nc.itf.zzjs.bd.constant.IChnlManagerConstant;
import nc.ui.trade.bill.ICardController;
import nc.ui.trade.bsdelegate.BusinessDelegator;
import nc.ui.trade.pub.IVOTreeDataByID;
import nc.vo.pub.SuperVO;

public class ChnlManagerTreeCardData implements IVOTreeDataByID {

	private SuperVO[] m_ChnlManagerVOs = null;
	
	private String pk_corp = null;
	
	private BusinessDelegator m_bsDelegator = null;
	
	private ICardController m_uiCtl = null;
	
	public ChnlManagerTreeCardData(String pk_corp,
			BusinessDelegator m_bsDelegator,
			ICardController m_uiCtl){
		this.pk_corp = pk_corp;
		this.m_bsDelegator = m_bsDelegator;
		this.m_uiCtl = m_uiCtl;
	}

	public String getIDFieldName() {
		return IChnlManagerConstant.TABLEKEY;
	}

	public String getParentIDFieldName() {
		return "pk_parent";
	}

	public String getShowFieldName() {
		return "positionname";
	}

	public SuperVO[] getTreeVO() {
		try {
			if (m_ChnlManagerVOs == null) {
				String strWhere = " isnull(mcm_chnlmanager.dr,0) = 0 and  mcm_chnlmanager.pk_corp='"+ pk_corp + "'";
				m_ChnlManagerVOs = m_bsDelegator.queryHeadAllData(
						Class.forName(m_uiCtl.getBillVoName()[1]),
						m_uiCtl.getBillType(), strWhere);
			}
		} catch (Exception e) {
			Logger.info(e);
		}
		return m_ChnlManagerVOs;
	}
}
